package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.dto.LuntaiEquipmentUseLogDto;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.LuntaiEquipmentUseLog;
import com.ruoyi.system.service.ILuntaiEquipmentUseLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 器材使用记录Controller
 * 
 * @author ruoyi
 * @date 2025-02-17
 */
@RestController
@RequestMapping("/system/equipmentUseLog")
public class LuntaiEquipmentUseLogController extends BaseController
{
    @Autowired
    private ILuntaiEquipmentUseLogService luntaiEquipmentUseLogService;

    /**
     * 查询器材使用记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:log:list')")
    @GetMapping("/list")
    public TableDataInfo list(LuntaiEquipmentUseLog luntaiEquipmentUseLog)
    {
        startPage();
        List<LuntaiEquipmentUseLog> list = luntaiEquipmentUseLogService.selectLuntaiEquipmentUseLogList(luntaiEquipmentUseLog);
        return getDataTable(list);
    }
    /**
     * 查询器材使用记录列表2
     */
    @PreAuthorize("@ss.hasPermi('system:log:list')")
    @GetMapping("/list2")
    public TableDataInfo list2(LuntaiEquipmentUseLogDto luntaiEquipmentUseLogDto)
    {
        startPage();
        List<LuntaiEquipmentUseLogDto> list = luntaiEquipmentUseLogService.selectLuntaiEquipmentUseLogList2(luntaiEquipmentUseLogDto);
        return getDataTable(list);
    }

    /**
     * 查询器材使用记录列表2
     */
    @PreAuthorize("@ss.hasPermi('system:log:list')")
    @GetMapping("/list3")
    public AjaxResult list3(@RequestParam Integer requestId)
    {
        List<LuntaiEquipmentUseLogDto> list = luntaiEquipmentUseLogService.selectLuntaiEquipmentUseLogList3(requestId);
        return AjaxResult.success(list);
    }

    /**
     * 导出器材使用记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:log:export')")
    @Log(title = "器材使用记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LuntaiEquipmentUseLog luntaiEquipmentUseLog)
    {
        List<LuntaiEquipmentUseLog> list = luntaiEquipmentUseLogService.selectLuntaiEquipmentUseLogList(luntaiEquipmentUseLog);
        ExcelUtil<LuntaiEquipmentUseLog> util = new ExcelUtil<LuntaiEquipmentUseLog>(LuntaiEquipmentUseLog.class);
        util.exportExcel(response, list, "器材使用记录数据");
    }

    /**
     * 获取器材使用记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:log:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(luntaiEquipmentUseLogService.selectLuntaiEquipmentUseLogById(id));
    }

    /**
     * 新增器材使用记录
     */
    @PreAuthorize("@ss.hasPermi('system:log:add')")
    @Log(title = "器材使用记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody List<LuntaiEquipmentUseLog> luntaiEquipmentUseLog)
    {
        return toAjax(luntaiEquipmentUseLogService.insertLuntaiEquipmentUseLog(luntaiEquipmentUseLog));
    }

    /**
     * 修改器材使用记录
     */
    @PreAuthorize("@ss.hasPermi('system:log:edit')")
    @Log(title = "器材使用记录", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody LuntaiEquipmentUseLog luntaiEquipmentUseLog)
    {
        return toAjax(luntaiEquipmentUseLogService.updateLuntaiEquipmentUseLog(luntaiEquipmentUseLog));
    }

    /**
     * 删除器材使用记录
     */
    @PreAuthorize("@ss.hasPermi('system:log:remove')")
    @Log(title = "器材使用记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(luntaiEquipmentUseLogService.deleteLuntaiEquipmentUseLogByIds(ids));
    }
}
